<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="ww" uri="webwork" %>
<form class="form-horizontal form-validate" name="orguser_form" id="orguser_form" action="addOrgUserOrg.action" onsubmit="return ou_add(this, closeDialogRefreshTabForm);">
	<input type="hidden" id="orgId" name="orgId" value="<ww:property value='orgId'/>">
	<input type="hidden" id="ids" name="ids" value="">
	<input type="hidden" id="orgids" name="orgids" value="">
	<div style="width: 400px;height: 250px; overflow: auto;">
		<ul id="orguser_tree" class="ztree"></ul>
	</div>
	<div class="set-btn" data-spy="affix" data-offset-top="200">
		<button class="btn green" type="button" onclick="$(this).submit();">保存</button>
		<a class="btn" href="javascript:;" onclick="$css.closeDialog()">取消</a>
	</div>
</form>
<script>
		var setting = {	
			check: {
				enable: true
			},
			data : {
				simpleData : {
					enable : true
				}
			}
		};
		var zNodes =<ww:property value="result"/>;
		var tree  = null;
		using('tree',function(){
			orguser_tree = $.fn.zTree.init($("#orguser_tree"), setting, zNodes);
		})
		function ou_add(form,callback){
			var nodes = orguser_tree.getCheckedNodes(true);
			var pars ="";
			var orgpars = "";
			for(var i in nodes){
				if(nodes[i].type == "user"){
				pars += nodes[i].id;
				orgpars += nodes[i].getParentNode().id;
				if(i<nodes.length-1){
					 pars+=",";
					 orgpars +=",";
				}
				}
			}
			$("#ids").val(pars);
			$("#orgids").val(orgpars);
			$action.submit(form,null,null, closeDialogRefreshTabForm);
			return false;
		}
</script>